/*
 * @Author: taiyunhang
 * @Date: 2018-12-12 09:49:25
 * */

const proxy = require('./src/env/proxy');
// import {
//   proxyPath,
//   proxyPathMap
// } from './src/env/proxy';
const staticPath = require('./src/env/static');
// import staticPath from './src/env/static';
// const debug = process.env.NODE_ENV !== 'production';
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const proxyPath = proxy.proxyPath;
const proxyPathMap = proxy.proxyPathMap;
module.exports = {
  // eslint-loader 是否在保存的时候检查
  lintOnSave: true,
  publicPath: staticPath,
  devServer: {
    host: '0.0.0.0',
    port: 2999,
    open: true,
    proxy: {
      [proxyPath]: {
        target: 'http://h5adm.schengle.com/h5-web-business/h5service/',
        changeOrigin: true,
        ws: true
        // pathRewrite: {
        //  '^/api': ''
        //} 
      },
      '/csp-web-website': {
        target: 'http://csp.schengle.com/csp-web-website/',
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/csp-web-website': ''
        }
      }
    }
  },
  configureWebpack: {
    optimization: {
      minimizer: [
        new UglifyJsPlugin({
          uglifyOptions: {
            compress: {
              warnings: false,
              drop_debugger: true,
              drop_console: true,
              pure_funcs: ['console.log'] // 移除console
            }
          }
        })
      ]
    }
  },
  // transpileDependencies: process.env.NODE_ENV === 'production' ? ['vue-qr'] : [],
  // 生产环境是否生成 sourceMap 文件
  productionSourceMap: true
};
